﻿/*
   ++++++++++++++++++++++++++++++++++++++++++++
   +  Description: 通用 js
   +  Created by 王大宸 on 2020-02-07 14:32
   +  Created with IntelliJ IDEA.
   ++++++++++++++++++++++++++++++++++++++++++++
 */

$(function () {
    $.ajaxSetup({
        beforeSend: function (jqXHR, settings) {
            if (settings.url.indexOf("?") === -1) {
                settings.url += "?time=" + new Date().getTime();
            } else {
                settings.url += "&time=" + new Date().getTime();
            }
        }
    });
});

/* 常用方法封装 */
(function ($) {
    $.extend({
        /* 搜索 */
        searchTable: {
            // 表格搜索框
            searchBtn: function (loadTable_fun) {
                $('#searchBtn').on('click', function () {
                        loadTable_fun();
                    }
                );
            }
        },
        /* layui 分页查询参数 */
        layui: {
            layPage: function (count, pageNum, limitNum, loadTable_fun) {
                layPage.render({
                    elem: 'layPage'
                    , count: count
                    , curr: pageNum
                    , limit: limitNum
                    , theme: '#1E9FFF'
                    , limits: [10, 15, 30]
                    , layout: ['prev', 'page', 'next', 'skip', 'refresh', 'limit', 'count']
                    , jump: function (obj, first) {
                        if (!first) {
                            page = obj.curr;
                            limit = obj.limit;
                            loadTable_fun();
                        }
                    }
                })
            }
        },

    });
})(jQuery);
